bool check_date(int date) {
  int year = date / 10000;
  int month = (date % 10000) / 100;
  int day = date % 100;
  static int monthDay[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  if (year < 0) {
    return false;
  }
  if (month <= 0 || month > 12) {
    return false;
  }
  bool leap = (year % 400 == 0 || (year % 100 && year % 4 == 0));
  int maxDay = monthDay[month];
  if (month == 2 && leap) {
    maxDay++;
  }
  return day > 0 && day <= maxDay;
}
